package org.javaboy.weixin_login.config;

import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest;
import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequestEntityConverter;
import org.springframework.util.MultiValueMap;

public class MyOAuth2AuthorizationCodeGrantRequestEntityConverter extends OAuth2AuthorizationCodeGrantRequestEntityConverter {
    @Override
    protected MultiValueMap<String, String> createParameters(OAuth2AuthorizationCodeGrantRequest authorizationCodeGrantRequest) {
        MultiValueMap<String, String> parameters = super.createParameters(authorizationCodeGrantRequest);
        if (authorizationCodeGrantRequest.getClientRegistration().getRegistrationId().equals("weixin")) {
            parameters.add("appid", authorizationCodeGrantRequest.getClientRegistration().getClientId());
            parameters.add("secret", authorizationCodeGrantRequest.getClientRegistration().getClientSecret());
        }
        return parameters;
    }
}
